package com.gxa.service.asset.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.asset.ConnectApply;
import com.gxa.entity.asset.ConnectRecord;
import com.gxa.entity.asset.search.ConnectApplySearchMap;
import com.gxa.service.asset.ConnectApplyService;
import com.gxa.mapper.asset.ConnectApplyMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
* @author Administrator
* @description 针对表【t_connect_apply(移交申请表)】的数据库操作Service实现
* @createDate 2022-10-13 11:16:24
*/
@Service
public class ConnectApplyServiceImpl extends ServiceImpl<ConnectApplyMapper, ConnectApply>
    implements ConnectApplyService{

    @Autowired
    private ConnectApplyMapper mapper;

    @Override
    public PageInfo<ConnectApply> queryByPage(ConnectApplySearchMap map) {
        PageHelper.startPage(map.getPageNum(),map.getPageSize());//1.开启分页

        QueryWrapper<ConnectApply> wrapper = new QueryWrapper<>();//2.条件构造器 模拟写动态sql  或者在xml 中写
        if (!StringUtils.isBlank(map.getApplyId())) {
            wrapper.like("connect_apply_num", map.getApplyId());
        }
        if(!StringUtils.isBlank(map.getApplyPerson())){
            wrapper.like("apply_person",map.getApplyPerson());
        }
        if(!StringUtils.isBlank(map.getDept())){
            wrapper.like("connect_apply_dep",map.getDept());
        }
        if(!StringUtils.isBlank(map.getStatus())){
            wrapper.eq("connect_apply_state",map.getStatus());
        }
        if(!StringUtils.isAnyBlank(map.getStartTime(),map.getEndTime())){
            wrapper.between("application_time",map.getStartTime(),map.getEndTime());
        }
        PageInfo<ConnectApply> pageInfo = new PageInfo<>(mapper.selectList(wrapper));//3.获取分页信息
        return pageInfo;
    }

    @Override
    public Set<String> getDepts() {
        return mapper.getDepts();
    }
}




